// CPP6 Chapter 7.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

typedef double (*pAdd)(double , double);

double calculate(double , double , pAdd);
double add(double, double);
double doubleadd(const double*, const double*);

const int ArrSize = 3;

using namespace std;

int main()
{
	pAdd pArrayToAdd[ArrSize] = {add, add, add};

	double x1;
	double x2;

	for(int i = 0;i < ArrSize;i++)
	{
		cout << "Ingrese un par de numeros" << endl;
		cout << "Numero 1" << endl;
		cin >> x1;
		cout << "Numero 2" << endl;
		cin >> x2;
		cout << "La suma de ambos numeros calculada magicamente es : " << calculate(x1 , x2 , *(pArrayToAdd + i)) << endl;
	}
	cin.get();
	cin.get();
}

double calculate(double x1 , double x2 , pAdd  pf)
{
	return (*pf)(x1 , x2);
}

double add(double x1 , double x2)
{
	return doubleadd(&x1 , &x2);
}

double doubleadd(const double* x1, const double* x2)
{
	return (*x1) + (*x2);
}





